
package gameoflife;

/**
 * Welcome to the UpdateRules Class.
 *
 * This class is designed to hold the update rules for the required simulated.
 *
 * @author CJ
 */
public class UpdateRules {

    //Instance Variables
    private int resulting[];

    //Constructors
    /**
     * Basic constructor for the update rules object.
     *
     * Assumes that all the arguments are valid.
     *
     * @param sum0Result, result if the sum of neighbors is 0
     * @param sum1Result, result if the sum of neighbors is 1
     * @param sum2Result, result if the sum of neighbors is 2
     * @param sum3Result, result if the sum of neighbors is 3
     */
    public UpdateRules(int sum0Result, int sum1Result, int sum2Result, int sum3Result){
        this.resulting = new int[4];
        this.resulting[0] = sum0Result;
        this.resulting[1] = sum1Result;
        this.resulting[2] = sum2Result;
        this.resulting[3] = sum3Result;
    }

    //Methods
    /**
     * Basic method that returns the result give the desired sum.
     *
     * @param sum, sum of the neighbors for returned result
     * @return result the corresponding result for the desired sum
     */
    public int getSumResult(int sum){

        //Sanity Check
        if(sum > 3 || sum < 0){
            throw new IllegalArgumentException("In getSumResult:UpdateRules," +
                    "passed in sum is non-valid.");
        }

        return this.resulting[sum];
    }


}
